<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
    <th:block th:include="include :: header('新增测试1')" />
</head>
<body class="white-bg">
    <div class="wrapper wrapper-content animated fadeInRight ibox-content">
        <form class="form-horizontal m" id="form-test1-add">
            <h4 class="form-header h4">测试1信息</h4>
            <div class="form-group">
                <label class="col-sm-3 control-label">名称：</label>
                <div class="col-sm-8">
                    <input name="name" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">测试1：</label>
                <div class="col-sm-8">
                    <input name="test1" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">测试2：</label>
                <div class="col-sm-8">
                    <input name="test2" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">测试3：</label>
                <div class="col-sm-8">
                    <input name="test3" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">测试4：</label>
                <div class="col-sm-8">
                    <input name="test4" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">测试5：</label>
                <div class="col-sm-8">
                    <input name="test5" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">测试6：</label>
                <div class="col-sm-8">
                    <input name="test6" class="form-control" type="text">
                </div>
            </div>
            <h4 class="form-header h4">测试1信息</h4>
            <div class="row">
                <div class="col-sm-12">
                    <button type="button" class="btn btn-white btn-sm" onclick="addColumn()"><i class="fa fa-plus"> 增加</i></button>
                    <button type="button" class="btn btn-white btn-sm" onclick="sub.delColumn()"><i class="fa fa-minus"> 删除</i></button>
                    <div class="col-sm-12 select-table table-striped">
                        <table id="bootstrap-table"></table>
                    </div>
                </div>
            </div>
        </form>
    </div>
    <th:block th:include="include :: footer" />
    <script th:inline="javascript">
        var prefix = ctx + "test/test1"
        $("#form-test1-add").validate({
            focusCleanup: true
        });

        function submitHandler() {
            if ($.validate.form()) {
                $.operate.save(prefix + "/add", $('#form-test1-add').serialize());
            }
        }

        $(function() {
            var options = {
                pagination: false,
                showSearch: false,
                showRefresh: false,
                showToggle: false,
                showColumns: false,
                sidePagination: "client",
                columns: [{
                    checkbox: true
                },
                {
                    field: 'index',
                    align: 'center',
                    title: "序号",
                    formatter: function (value, row, index) {
                    	var columnIndex = $.common.sprintf("<input type='hidden' name='index' value='%s'>", $.table.serialNumber(index));
                    	return columnIndex + $.table.serialNumber(index);
                    }
                },
                {
                    field: 'name',
                    align: 'center',
                    title: '名称',
                    formatter: function(value, row, index) {
                        var html = $.common.sprintf("<input class='form-control' type='text' name='test1SubList[%s].name' value='%s'>", index, value);
                        return html;
                    }
                },
                {
                    field: 'test1',
                    align: 'center',
                    title: '测试1',
                    formatter: function(value, row, index) {
                        var html = $.common.sprintf("<input class='form-control' type='text' name='test1SubList[%s].test1' value='%s'>", index, value);
                        return html;
                    }
                },
                {
                    field: 'test2',
                    align: 'center',
                    title: '测试2',
                    formatter: function(value, row, index) {
                        var html = $.common.sprintf("<input class='form-control' type='text' name='test1SubList[%s].test2' value='%s'>", index, value);
                        return html;
                    }
                },
                {
                    field: 'test3',
                    align: 'center',
                    title: '测试3',
                    formatter: function(value, row, index) {
                        var html = $.common.sprintf("<input class='form-control' type='text' name='test1SubList[%s].test3' value='%s'>", index, value);
                        return html;
                    }
                },
                {
                    field: 'test4',
                    align: 'center',
                    title: '测试4',
                    formatter: function(value, row, index) {
                        var html = $.common.sprintf("<input class='form-control' type='text' name='test1SubList[%s].test4' value='%s'>", index, value);
                        return html;
                    }
                },
                {
                    field: 'test5',
                    align: 'center',
                    title: '测试5',
                    formatter: function(value, row, index) {
                        var html = $.common.sprintf("<input class='form-control' type='text' name='test1SubList[%s].test5' value='%s'>", index, value);
                        return html;
                    }
                },
                {
                    field: 'test6',
                    align: 'center',
                    title: '测试6',
                    formatter: function(value, row, index) {
                        var html = $.common.sprintf("<input class='form-control' type='text' name='test1SubList[%s].test6' value='%s'>", index, value);
                        return html;
                    }
                },
                ]
            };
            $.table.init(options);
        });

        function addColumn() {
            var count = $("#" + table.options.id).bootstrapTable('getData').length;
            sub.editColumn();

            $("#" + table.options.id).bootstrapTable('insertRow', {
                index: count,
                row: {
                    index: $.table.serialNumber(count),
                    name: "",

                    test1: "",

                    test2: "",

                    test3: "",

                    test4: "",

                    test5: "",

                    test6: "",

                }
            });
        }
    </script>
</body>
</html>
